Skip to content

Fix PHP 8.4 ValueError when str_getcsv() receives empty enclosure#165

Open
richardlhr wants to merge 1 commit into
brewlabs:masterfrom
richardlhr:fix/php84-str-getcsv-enclosure
Open

Fix PHP 8.4 ValueError when str_getcsv() receives empty enclosure#165
richardlhr wants to merge 1 commit into
brewlabs:masterfrom
richardlhr:fix/php84-str-getcsv-enclosure

Conversation

@richardlhr

Copy link
Copy Markdown

Summary

Fixes a PHP 8+ compatibility issue in SendPress_Data::csv_to_array().

When csv_to_array() is called without an enclosure argument, the default value is an empty string:

$enclosure = '';

This value is then passed directly to:

str_getcsv($csv_line, $delimiter, $enclosure);

PHP 8+ now throws:

ValueError: str_getcsv(): Argument #3 ($enclosure) must be a single character

because the enclosure parameter must contain exactly one character.

Fix

Use the standard CSV enclosure character (") when no enclosure is provided.

This restores compatibility with PHP 8.x while preserving existing behavior.

Tested

  • PHP 8.1
  • PHP 8.2
  • PHP 8.3
  • PHP 8.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant